<template>
    <div class="tuishou-tixian">
        <div class="tuishou-tixian-card">
            <div class="tuishou-tixian-head">
                <Row :gutter="5">
                    <Col span="3">
                        <DatePicker  clearable v-model="searchData.timeStartEnd" style="width: 100%" type="daterange" placeholder="时间筛选"></DatePicker>
                    </Col>
                    <Col span="3">
                        <Input clearable v-model="searchData.phone" placeholder="用户电话" type="text"></Input>
                    </Col>
                    <Col span="3">
                        <Input clearable v-model="searchData.bankName" placeholder="开户行姓名" type="text"></Input>
                    </Col>
                    <Col span="3">
                        <Input clearable v-model="searchData.cardNumber" placeholder="银行卡号" type="text"></Input>
                    </Col>
                    <Col span="3">
                        <Select clearable v-model="searchData.status" placeholder="审核状态">
                            <Option value="0">审核中</Option>
                            <Option value="1">已通过</Option>
                            <Option value="-1">已驳回</Option>
                        </Select>
                    </Col>
                    <Col span="3">
                        <Select clearable v-model="searchData.isTimeUp" placeholder="创建时间排序">
                            <Option :value="1">升序</Option>
                            <Option :value="2">降序</Option>
                        </Select>
                    </Col>
                    <Col span="6">
                        <Button :loading="search_loading" @click="searchGetList" class="subSearch" type="primary"><Icon type="ios-pulse-strong"></Icon> 筛 选</Button>
                    </Col>
                </Row>
            </div>
            <i-table height="680" stripe :columns="columns" :data="data"></i-table>
            <div style="padding: 15px;">
                <Page @on-page-size-change="changeTiao" @on-change="changePage" :current="index" :total="total" show-elevator show-sizer :placement="'top'" :page-size="page_con" :page-size-opts="[10, 15, 20, 30, 40, 50]"></Page>
            </div>
        </div>
        <!--审核通过-->
        <Modal v-model="modal1" width="360">
            <p slot="header" style="text-align:center">
                <a>
                    <Icon type="information-circled"></Icon>
                    <span>审核通过</span>
                </a>
            </p>
            <div style="text-align:center">
                <p>确定通过此提现?</p>
            </div>
            <div slot="footer">
                <Button type="primary" size="large" long :loading="modal_loading" @click="delShop">确定</Button>
            </div>
        </Modal>
        <!--审核驳回-->
        <Modal v-model="modal2" width="360">
            <p slot="header" style="text-align:center">
                <a>
                    <Icon type="information-circled"></Icon>
                    <span>审核驳回</span>
                </a>
            </p>
            <div style="text-align:center">
                <p>确定驳回此提现?</p>
            </div>
            <div slot="footer">
                <Button type="primary" size="large" long :loading="modal_loading" @click="resetPwd">确定</Button>
            </div>
        </Modal>
    </div>
</template>
<script>
    export default {
        name:"tuishou-tixian",
        data(){
            return{
                columns:[
                    {
                        title: '序号',
                        type: 'index',
                        width: 60,
                        align:"center",
                    },
                    {
                        title: '用户电话',
                        key: 'loginname',
                        align:"center",
                    },
                    {
                        title: '开户行姓名',
                        key: 'kaihuhang',
                        align:"center",
                    },
                    {
                        title: '银行卡号',
                        key: 'card_number',
                        align:"center",
                    },
                    {
                        title: '提现金额',
                        key: 'money_total',
                        align:"center",
                        render:(h,params)=>{
                            return `￥${params.row.money_total}`
                        }
                    },
                    {
                        title: '手续费',
                        key: 'withdraw_fee',
                        align:"center",
                        render:(h,params)=>{
                            return `￥${params.row.withdraw_fee}`
                        }
                    },
                    {
                        title: '状态',
                        key: 'status',
                        align:"center",
                        render:(h,params)=>{
                            if(params.row.status=="0"){
                                return `审核中`
                            }else if(params.row.status=="1"){
                                return `已通过`
                            }else{
                                return `已驳回`
                            }
                        }
                    },
                    {
                        title: '提现时间',
                        key: 'add_time',
                        align:"center",
                        render:(h,params)=>{
                            return this.timeFormat(params.row.add_time)
                        }
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width:200,
                        align: 'center',
                        render: (h, params) => {
                            if(params.row.status==0){
                                return h('ButtonGroup', [
                                    h('Button', {
                                        props: {
                                            type: 'warning',
                                        },
                                        on: {
                                            click: () => {
                                                this.id = params.row.withdraw_id
                                                this.modal1=true
                                            }
                                        }
                                    },"审核通过"),
                                    h('Button', {
                                        props: {
                                            type: 'error',
                                        },
                                        on: {
                                            click: () => {
                                                this.id = params.row.withdraw_id
                                                this.modal2=true
                                            }
                                        }
                                    }, '审核驳回')
                                ]);
                            }else{
                                return "暂无操作"
                            }

                        }
                    },
                ],
                data:[],
                total:0,
                index:1,
                page_con:15,
                modal_loading:false,
                searchData:{
                    timeStartEnd:[],//两个时间内的赛选
                    status:"",//状态
                    isTimeUp:"",//时间排序
                    phone:"",//登录电话
                    bankName:"",//开户行姓名
                    cardNumber:"",//银行卡号
                },
                search_loading:false,
                id:"",//操作的ID
                modal1:false,
                modal2:false,
            }
        },
        activated(){
            this.getGoodsBrand()
        },
        methods:{
            getGoodsBrand(){
                this.getJsonData("Withdraw/tuishouWithdrawList",{
                    num:this.page_con,
                    page:this.index,
                    begin:this.searchData.timeStartEnd[0]?this.searchData.timeStartEnd[0]/1000:"",
                    last:this.searchData.timeStartEnd[1]?this.searchData.timeStartEnd[1]/1000:"",
                    status:this.searchData.status,
                    phone:this.searchData.phone,
                    bank:this.searchData.bankName,
                    card_number:this.searchData.cardNumber,
                    sort:this.searchData.isTimeUp,
                },true)
                    .then((res)=>{
                        this.data=res.data
                        this.total=parseInt(res.count)
                        this.search_loading=false
                    })
                    .catch((res)=>{
                        this.search_loading=false
                    })
            },
            changePage(n){
                this.index=n
                this.getGoodsBrand()
            },
            changeTiao(num){
                this.page_con=num
                this.index=1
                this.getGoodsBrand()
            },
            remove(n){
                this.doIndex=n
                this.modal2=true
            },
            searchGetList(){
                this.search_loading=true
                this.index=1
                this.getGoodsBrand()
            },
            //删除店铺
            delShop(){
                this.modal_loading = true;
                this.getJsonData("Withdraw/adoptTwithdraw",{withdraw_id:this.id},true)
                    .then((res)=>{
                        this.getGoodsBrand()
                        this.modal_loading = false;
                        this.modal1 = false;
                        this.$Message.success('审核已通过');
                    }).catch((res)=>{
                    this.modal_loading = false;
                    this.modal1 = false;
                })
            },
            //重置密码
            resetPwd(){
                this.modal_loading = true;
                this.getJsonData("Withdraw/cancelTwithdraw",{withdraw_id:this.id},true)
                    .then((res)=>{
                        this.getGoodsBrand()
                        this.modal_loading = false;
                        this.modal2 = false;
                        this.$Message.success('审核已驳回');
                    }).catch((res)=>{
                    this.modal_loading = false;
                    this.modal2 = false;
                })
            }
        },
    }
</script>
<style lang="less">
    @import "tuishou-tixian";
</style>